package com.learn.common.utils;

import com.learn.common.enums.ResultEnum;
import lombok.Data;
import org.joda.time.DateTime;

import java.util.List;

/**
 * Created by zhaohongwei1@itcast.cn
 */
@Data
public class PageResult<T> {
    private Long count;// 总条数
    private List<T> data;// 当前页数据
    private String timestamp;
    private String msg;
    private Integer state;
    private Integer praise = 0;

    public PageResult() {
    }

    public PageResult(Long count , List<T> data, String msg, Integer state) {
        this.count = count;
        this.data = data;
        this.msg = msg;
        this.state = state;

        timestamp = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
    }

    public PageResult(Long count , List<T> data, ResultEnum resultEnum) {
        this.count = count;
        this.data = data;
        this.msg = resultEnum.getMsg();
        this.state = resultEnum.getState();

        timestamp = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
    }
    public PageResult(Long count , List<T> data, ResultEnum resultEnum,Integer praise) {
        this.count = count;
        this.data = data;
        this.msg = resultEnum.getMsg();
        this.state = resultEnum.getState();
        this.praise = praise;
        timestamp = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
    }
}
